/***********************************************************************************************************************
 * 
 * > QuadroCore <
 * 
 * Copyright (C) 2012 by Chris Channing
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************/

#include "quadrocore.h"

int main(void)
{	
	DisableGlobalInterrupts();
	{		
		SystemClockInit();
		PMICInit();
		LCDInit(false);
		USBModuleInit();
	}
	EnableGlobalInterrupts();
	
	SplashScreen();
	
	for ( ; ; )
	{
		// keep looping forever (we are interrupt driven)
	}
	
	return 0;
}

void SplashScreen(void)
{
	LCDEnableBackLight();
	LCDWriteString(5, 20, "Booting...", NULL, BLACK);
	LCDCanvasFlush();
	wait(500);
	
	{
		uint8_t x = 5;
	
		for (uint8_t count = 0; count < (LCD_WIDTH / 12); count++)
		{		
			LCDCanvasDrawBox(x, 5, 10, 10, true);
			LCDCanvasFlush();
			wait(250);		
		
			x += 12;
		}
	}
		
	LCDCanvasClear();
	LCDCanvasDrawBox(0, 15, 14, LCD_WIDTH - 1, true);
	LCDWriteString(4, 18, "> QuadroCore <", NULL, WHITE);
	LCDWriteString(80, 2, VERSION_LITERAL, NULL, BLACK);
	LCDCanvasFlush();
	
	wait(10000);
	LCDDisableBackLight();
}